<?php use_helper('Pagination'); ?>

    <?php include_partial('back/show', array('uri' => '@localized_homepage')); ?>
    <h1 class="title">Derniers commentaires</h1>
<!--    <div class="navPages"><?php //echo pager_navigation($last_comments_list, url_for('@last_comments')); ?></div>-->
<!--    <div class="push_float"></div>-->

    <ul class="last-comments">
        <?php
            $link_html = "";
            $array_record_id = array('News' => null, 'Event' => null);
            foreach($last_comments_list as $comment){
                $link = get_partial('lastComments/linkComment', array('comment' => $comment));
                $contentLink = $comment[ 'title' ];
                $link_html = link_to($contentLink, $link);
            ?>
                <li class="comment">
                    <div class="comment-head">
                         <?php $sfAsset = array('filename' => $comment[ 'filename' ], 
                                                'original_width' => $comment[ 'original_width' ],
                                                'original_height' => $comment[ 'original_height' ],
                                                'large_width' => $comment[ 'large_width' ],
                                                'large_height' => $comment[ 'large_height' ],
                                                'small_width' => $comment[ 'small_width' ],
                                                'small_height' => $comment[ 'small_height' ])
                         ?>

                         <?php $imagesAttributes = Utils::getImageSize($comment[ 'relative_path' ], $sfAsset, 48, 42); ?>
                         <?php $hasAvatar = !is_null($comment['filename']) ? true : false; ?>

                         <div class="avatar-box">
                             <div class="content-avatar-box">
                                 <?php if($hasAvatar && !$comment['is_delete']): ?>
                                     <?php echo image_tag($imagesAttributes['small']['url'], array('title' => $comment['filename'], 'width' => $imagesAttributes['small']['width'], 'height' => $imagesAttributes['small']['height'], 'style' => 'margin-top: ' . $imagesAttributes['small']['marginTop'] . 'px; margin-left: ' . $imagesAttributes['small']['marginLeft'] . 'px')) ?>
                                 <?php else: ?>
                                     <?php echo image_tag('/images/noavatar.png', array('title' => 'aucun avatar', 'width' => '48', 'height' => '42')) ?>
                                 <?php endif ?>
                             </div>
                         </div>

                         <div class="author">
                             écrit par <?php echo ($comment[ 'username' ] ? $comment[ 'username' ] : $comment[ 'author_name' ]) ?>
                             <span class="date">Le <?php echo $comment[ 'updated_at' ] ?></span>
                             <?php if($comment['author_website']){ ?>
                                <span class="website">Site / Blog : <?php echo link_to(truncate_text($comment['author_website'], 40, '...'), $comment['author_website'], array('target' => '_blank')) ?></span>
                            <?php } ?>
                         </div>
                     </div>
                     <div class="comment-body">
                         <?php echo truncate_text(strip_tags($comment->getRaw('body')), 200, '...') ?>
                         <br/>
                         <?php echo '&#187; ' . $link_html ?>
                     </div>
                </li>
        <?php }?>
    </ul>
    <div class="push_float"></div>